package com.db.mapper;

import com.db.pojo.Information;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

/**
 * 实现查找基础信息表所有表信息
 *
 * @Createtime ：2020-01-06
 * @Creator ：JingChu
 * @finishtime :2020-04-02
 */
@Mapper
public interface InformationMapper {
    //基础信息表操作
    @Select("SELECT * FROM information")
    List<Information> getInformationList();

    @Select("SELECT * FROM information WHERE TABLE_NAME=#{table} ")
    Information getInformation(@Param("table") String table);

    @Update("UPDATE information SET ID_INDEX=#{update_index} WHERE TABLE_NAME=#{table} AND ID_INDEX=#{index}")
    int updateIdIndex(@Param("table") String table, @Param("index") int index, @Param("update_index") int update_index);


    //插入操作记录
    @Insert("INSERT INTO records (id,associator,openid,op_desc,op_type,article) VALUE (${filedsValue})")
    int insertRecords(@Param("filedsValue") String filedsValue);

    //单表操作
    @Insert("INSERT INTO ${table} (${fieldsName}) VALUE (${filedsValue})")
    int insertTable(@Param("table") String table, @Param("fieldsName") String fieldsName, @Param("filedsValue") String filedsValue);

    @Update("UPDATE  ${table} SET ${setSql} WHERE id=#{id}")
    int updateTable(@Param("table") String table, @Param("setSql") String setSql, @Param("id") String id);

    @Select("SELECT ${fieldsMsg} FROM ${table} WHERE id=#{id}")
    Map<String, Object> selectTable(@Param("table") String table, @Param("id") String id, @Param("fieldsMsg") String fieldsMsg);

    @Select("SELECT ${fieldsMsg} FROM ${table} WHERE 1=1 ${qeurySql}")
    List<Map<String, Object>> selectTableList(@Param("table") String table, @Param("fieldsMsg") String fieldsMsg, @Param("qeurySql") String qeurySql);
}
